package com.luban.service;

import com.luban.entity.User;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class UserService implements InitializingBean {

	@Value("testkzx2222")
	public User userTest;

	public OrderService orderService;

	@Autowired  //用@Autowired时没有set方法也行
	public OrderService orderService2;

	public OrderService getOrderService() {
		return orderService;
	}

	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
		System.out.println("调用了setOrderService方法...");
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("UserService设置完属性之后调用afterPropertiesSet。。。");
	}


	@PostConstruct
	public void initXxx() { //在afterPropertiesSet前执行,而且TestBeanPostProcessor的postProcessBeforeInitialization的返回值不能是null
		System.out.println("初始化UserService--initXxx()。。。");
	}


	public void test() {
		System.out.println("test   kuan控制。。。匡振曦");
	}

	public void test2() {
		System.out.println(orderService);
	}
}
